// ml:run = $bin < input
#include <iostream>
#include <string>

int const maxn = 100007;
int sum[maxn];
int n;
std::string s;

int main()
{
    std::ios_base::sync_with_stdio(false);
    int T; std::cin >> T;
    while (T--) {
        std::cin >> n >> s;
        int c1 = 0, c2 = 0;
        if (n & 1) {
            std::cout << "No\n";
            continue;
        }
        bool first = true;
        int pos = 0;
        for (int i = 1; i <= n; i++) {
            sum[i] = sum[i - 1] + (s[i - 1] == '(' ? 1 : -1);
            if (s[i - 1] == '(') c1++;
            else c2++;
            if (sum[i] == -1 && first) {
                sum[i] += 2;
                first = false;
                pos = i;
            }
        }
        if (c1 != c2) { std::cout << "No\n"; continue; }
        if (first && !sum[n]) { std::cout << "Yes\n"; continue; }

        int last = n + 1;
        for (int i = n; i > pos; i--) {
            if (sum[i] < 2) break;
            if (s[i - 1] == '(') last = i;
        }

        if (last == n + 1) { std::cout << "No\n"; continue; }
        s[last - 1] = ')'; s[pos - 1] = '(';
        bool ok = true;
        for (int i = 1; i <= n; i++) {
            sum[i] = sum[i - 1] + (s[i - 1] == '(' ? 1 : -1);
            if (sum[i] == -1) { ok = false; break; }
        }
        if (sum[n]) ok = false;
        if (!ok) std::cout << "No\n";
        else std::cout << "Yes\n";
    }
}

